home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / fs / fsOpTable.c < prev    next >
C/C++ Source or Header  |  1990-10-10  |  5KB  |  153 lines

  1. /* 
  2.  * fsOpTable.c --
  3.  *
  4.  *    The operation tables for the file system.  Skeletons are defined
  5.  *    here, and they are initialized via calls by each module.  There
  6.  *    are 4 main operation tables.  The 'Domain Lookup' routines are
  7.  *    operations on pathnames.  The 'File Open' routines are invoked
  8.  *    on the file server depending on the type of file being opened -
  9.  *    these routines do preliminary open-time setup.  The 'Stream Op'
  10.  *    table are the object-specific routines on I/O streams.  Finally,
  11.  *    there is also an 'Attr Op' table used when getting attributes
  12.  *    of objects.
  13.  *
  14.  * Copyright 1987 Regents of the University of California
  15.  * All rights reserved.
  16.  * Permission to use, copy, modify, and distribute this
  17.  * software and its documentation for any purpose and without
  18.  * fee is hereby granted, provided that the above copyright
  19.  * notice appear in all copies.  The University of California
  20.  * makes no representations about the suitability of this
  21.  * software for any purpose.  It is provided "as is" without
  22.  * express or implied warranty.
  23.  */
  24.  
  25. #ifndef lint
  26. static char rcsid[] = "$Header: /sprite/src/kernel/fs/RCS/fsOpTable.c,v 9.2 90/10/08 11:04:08 mendel Exp $ SPRITE (Berkeley)";
  27. #endif not lint
  28.  
  29.  
  30. #include <sprite.h>
  31. #include <fs.h>
  32. #include <fsutil.h>
  33. #include <fsNameOps.h>
  34. #include <fsdm.h>
  35.  
  36. #include <stdio.h>
  37.  
  38. static ReturnStatus NoProc();
  39.  
  40. /*
  41.  * Domain specific routine table for lookup operations.
  42.  * The following operate on a single pathname.  They are called via
  43.  * Fsprefix_LookupOperation with arguments described in fsOpTable.h
  44.  *    DomainImport
  45.  *    DomainExport
  46.  *    DomainOpen
  47.  *    DomainGetAttrPath
  48.  *    DomainSetAttrPath
  49.  *    DomainMakeDevice
  50.  *    DomainMakeDir
  51.  *    DomainRemove
  52.  *    DomainRemoveDir
  53.  * The following operate on two pathnames.
  54.  *    DomainRename
  55.  *    DomainHardLink
  56.  */
  57.  
  58. /*
  59.  * THIS ARRAY INDEXED BY DOMAIN TYPE.  Do not arbitrarily insert entries.
  60.  */
  61. ReturnStatus (*fs_DomainLookup[FS_NUM_DOMAINS][FS_NUM_NAME_OPS])() = {
  62. /* FS_LOCAL_DOMAIN */
  63.     {NoProc, NoProc, NoProc, NoProc,
  64.      NoProc, NoProc, NoProc,
  65.      NoProc, NoProc, NoProc, NoProc},
  66. /* FS_REMOTE_SPRITE_DOMAIN */
  67.      {NoProc, NoProc, NoProc, NoProc,
  68.      NoProc, NoProc, NoProc,
  69.      NoProc, NoProc, NoProc, NoProc},
  70. /* FS_PSEUDO_DOMAIN */
  71.     {NoProc, NoProc, NoProc, NoProc,
  72.      NoProc, NoProc, NoProc,
  73.      NoProc, NoProc, NoProc, NoProc},
  74. /* FS_NFS_DOMAIN */
  75.     {NoProc, NoProc, NoProc, NoProc,
  76.      NoProc, NoProc, NoProc,
  77.      NoProc, NoProc, NoProc, NoProc},
  78. };
  79.  
  80. /*
  81.  * Domain specific get/set attributes table.  These routines are used
  82.  * to get/set attributes on the name server given a fileID (not a pathname).
  83.  */
  84. Fs_AttrOps fs_AttrOpTable[FS_NUM_DOMAINS] = {
  85. /* FS_LOCAL_DOMAIN */
  86.     { NoProc, NoProc },
  87. /* FS_REMOTE_SPRITE_DOMAIN */
  88.     { NoProc, NoProc },
  89. /* FS_PSEUDO_DOMAIN */
  90.     { NoProc, NoProc },
  91. /* FS_NFS_DOMAIN */
  92.     { NoProc, NoProc },
  93. };
  94.  
  95. static ReturnStatus
  96. NoProc()
  97. {
  98.     return(FAILURE);
  99. }
  100.  
  101. /*
  102.  *----------------------------------------------------------------------
  103.  *
  104.  * Fs_InstallDomainLookupOps --
  105.  *
  106.  *    Install the fs_DomainLookup entry for a particular domain type.
  107.  *
  108.  * Results:
  109.  *    None.
  110.  *
  111.  * Side effects:
  112.  *    The fs_DomainLookup table is modified.
  113.  *
  114.  *----------------------------------------------------------------------
  115.  */
  116.  
  117. void
  118. Fs_InstallDomainLookupOps(domainType, lookupOpsPtr, attrOpTablePtr)
  119.     int        domainType;    /* Domain type - FS_LOCAL_DOMAIN, 
  120.                  * FS_REMOTE_SPRITE_DOMAIN, etc. */
  121.     Fs_DomainLookupOps *lookupOpsPtr;
  122.                 /* Name operation routines for the domain. */
  123.     Fs_AttrOps       *attrOpTablePtr; /* Domain specific get/set attributes table.
  124.                      * entry for the domain. */
  125. {
  126.     int    i;
  127.  
  128.     if ((domainType < 0) || (domainType >= FS_NUM_DOMAINS)) {
  129.     printf("Bad domain type %d in Fs_InstallDomainLookupOps\n", domainType);
  130.     return;
  131.     }
  132.     fs_DomainLookup[domainType][FS_DOMAIN_IMPORT] = lookupOpsPtr->import;
  133.     fs_DomainLookup[domainType][FS_DOMAIN_EXPORT] = lookupOpsPtr->export;
  134.     fs_DomainLookup[domainType][FS_DOMAIN_OPEN] = lookupOpsPtr->open;
  135.     fs_DomainLookup[domainType][FS_DOMAIN_GET_ATTR] = lookupOpsPtr->getAttrPath;
  136.     fs_DomainLookup[domainType][FS_DOMAIN_SET_ATTR] = lookupOpsPtr->setAttrPath;
  137.     fs_DomainLookup[domainType][FS_DOMAIN_MAKE_DEVICE] = 
  138.                         lookupOpsPtr->makeDevice;
  139.     fs_DomainLookup[domainType][FS_DOMAIN_MAKE_DIR] = lookupOpsPtr->makeDir;
  140.     fs_DomainLookup[domainType][FS_DOMAIN_REMOVE] = lookupOpsPtr->remove;
  141.     fs_DomainLookup[domainType][FS_DOMAIN_REMOVE_DIR] = lookupOpsPtr->removeDir;
  142.     fs_DomainLookup[domainType][FS_DOMAIN_RENAME] = lookupOpsPtr->rename;
  143.     fs_DomainLookup[domainType][FS_DOMAIN_HARD_LINK] = lookupOpsPtr->hardLink;
  144.     for (i = 0; i < FS_NUM_NAME_OPS; i++) { 
  145.     if ((char *)(fs_DomainLookup[domainType][i]) == (char *) 0) {
  146.         panic(
  147.     "Fs_InstallDomainLookupOps missing routine for domainType %d\n", 
  148.             domainType);
  149.     }
  150.     }
  151.     fs_AttrOpTable[domainType] = *attrOpTablePtr;
  152. }
  153.